
package Cliente;

import callProcs.ProcsInsertar;
import java.lang.String;
import javax.swing.JFrame;
import java.math.BigInteger;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;



public class NuevoCliente extends javax.swing.JFrame {
    int IdDepartamento;
    /** Creates new form NuevoCliente */
    public NuevoCliente() {
        initComponents();

        JFrame.setDefaultLookAndFeelDecorated(true);

        ProcsInsertar InCliente = new ProcsInsertar();
        try {
            java.sql.ResultSet rs= InCliente.verDepartementos();
            while (rs.next()){
                cDepto.addItem(rs.getObject("Nombre_departamento"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(NuevoCliente.class.getName()).log(Level.SEVERE, null, ex);
        }
       
            
       

    }

   
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        Apellido = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        tNombre = new javax.swing.JTextField();
        tApellido = new javax.swing.JTextField();
        cDia = new javax.swing.JComboBox();
        cMes = new javax.swing.JComboBox();
        cAnio = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        rSoltero = new javax.swing.JRadioButton();
        rSi = new javax.swing.JRadioButton();
        rCasado = new javax.swing.JRadioButton();
        rNo = new javax.swing.JRadioButton();
        jLabel14 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        cDepto = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        tDir = new javax.swing.JTextField();
        cMunicipio = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        cZona = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        cOrden = new javax.swing.JComboBox();
        nDpi = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        registro = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        tcasa = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        tcel = new javax.swing.JTextField();

        jLabel1.setName("jLabel1"); // NOI18N

        jPanel4.setName("jPanel4"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(bufete.BufeteApp.class).getContext().getResourceMap(NuevoCliente.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setName("Form"); // NOI18N

        jLabel21.setName("jLabel21"); // NOI18N

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        Apellido.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        Apellido.setName("Apellido"); // NOI18N

        jLabel16.setFont(resourceMap.getFont("jLabel16.font")); // NOI18N
        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        tNombre.setName("tNombre"); // NOI18N

        tApellido.setName("tApellido"); // NOI18N

        cDia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        cDia.setName("cDia"); // NOI18N

        cMes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));
        cMes.setName("cMes"); // NOI18N

        cAnio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030", "2031", "2032", "2033", "2034", "2035", "2036", "2037", "2038", "2039", "2040", "2041", "2042", "2043", "2044", "2045", "2046", "2047", "2048", "2049", "2050" }));
        cAnio.setName("cAnio"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        rSoltero.setText(resourceMap.getString("rSoltero.text")); // NOI18N
        rSoltero.setName("rSoltero"); // NOI18N
        rSoltero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rSolteroActionPerformed(evt);
            }
        });

        rSi.setText(resourceMap.getString("rSi.text")); // NOI18N
        rSi.setName("rSi"); // NOI18N
        rSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rSiActionPerformed(evt);
            }
        });

        rCasado.setText(resourceMap.getString("rCasado.text")); // NOI18N
        rCasado.setName("rCasado"); // NOI18N
        rCasado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rCasadoActionPerformed(evt);
            }
        });

        rNo.setText(resourceMap.getString("rNo.text")); // NOI18N
        rNo.setName("rNo"); // NOI18N
        rNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rNoActionPerformed(evt);
            }
        });

        jLabel14.setIcon(resourceMap.getIcon("jLabel14.icon")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        javax.swing.GroupLayout ApellidoLayout = new javax.swing.GroupLayout(Apellido);
        Apellido.setLayout(ApellidoLayout);
        ApellidoLayout.setHorizontalGroup(
            ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ApellidoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ApellidoLayout.createSequentialGroup()
                        .addGap(53, 53, 53)
                        .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                            .addComponent(jLabel2)))
                    .addGroup(ApellidoLayout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(40, 40, 40)
                .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ApellidoLayout.createSequentialGroup()
                        .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)
                            .addComponent(tApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 417, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(ApellidoLayout.createSequentialGroup()
                                .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cDia, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(rSi))
                                .addGap(18, 18, 18)
                                .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(rNo)
                                    .addComponent(rCasado)
                                    .addGroup(ApellidoLayout.createSequentialGroup()
                                        .addComponent(cMes, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(cAnio, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                        .addGap(46, 46, 46))
                    .addComponent(rSoltero))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel14)
                .addGap(15, 15, 15))
        );
        ApellidoLayout.setVerticalGroup(
            ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ApellidoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(ApellidoLayout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2)
                            .addComponent(tNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(ApellidoLayout.createSequentialGroup()
                                .addGap(11, 11, 11)
                                .addComponent(tApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(ApellidoLayout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(ApellidoLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cDia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cAnio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(ApellidoLayout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addComponent(jLabel4)))
                        .addGap(18, 18, 18)
                        .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(ApellidoLayout.createSequentialGroup()
                                .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(rSoltero))
                                .addGap(1, 1, 1))
                            .addComponent(rCasado))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(ApellidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(rSi)
                    .addComponent(rNo)))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel2.setName("jPanel2"); // NOI18N

        jLabel11.setFont(resourceMap.getFont("jLabel11.font")); // NOI18N
        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        cDepto.setName("cDepto"); // NOI18N
        cDepto.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cDeptoItemStateChanged(evt);
            }
        });

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N

        tDir.setName("tDir"); // NOI18N

        cMunicipio.setName("cMunicipio"); // NOI18N

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        cZona.setName("cZona"); // NOI18N
        cZona.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cZonaActionPerformed(evt);
            }
        });
        cZona.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cZonaKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel11))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel13)
                            .addComponent(jLabel12)
                            .addComponent(jLabel20))
                        .addGap(39, 39, 39)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cDepto, 0, 440, Short.MAX_VALUE)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(tDir, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel15)
                                    .addGap(28, 28, 28)
                                    .addComponent(cZona, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(cMunicipio, javax.swing.GroupLayout.PREFERRED_SIZE, 440, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(213, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(cDepto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(cMunicipio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cZona, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel20)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel3.setName("jPanel3"); // NOI18N

        jLabel7.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        cOrden.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "A-1", "B-2", "C-3", "D-4", "E-5", "F-6", "G-7", "H-8", "I-9", "J-10", "K-11", "L-12", "M-13", "N-14", "O-15", "P-16", "Q-17", "R-18", "S-19", "T-20", "U-21", "V-22" }));
        cOrden.setName("cOrden"); // NOI18N

        nDpi.setName("nDpi"); // NOI18N
        nDpi.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                nDpiKeyTyped(evt);
            }
        });

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        registro.setName("registro"); // NOI18N
        registro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                registroKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addGap(54, 54, 54)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(54, 54, 54)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(cOrden, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(28, 28, 28)
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(registro))
                            .addComponent(nDpi, javax.swing.GroupLayout.PREFERRED_SIZE, 445, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(201, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(registro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10)
                    .addComponent(cOrden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(nDpi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel5.setName("jPanel5"); // NOI18N

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        tcasa.setName("tcasa"); // NOI18N
        tcasa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tcasaKeyTyped(evt);
            }
        });

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        tcel.setName("tcel"); // NOI18N
        tcel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tcelKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel17))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(jLabel18)
                        .addGap(31, 31, 31)
                        .addComponent(tcasa, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tcel, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(227, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(tcasa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(tcel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(45, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(496, 496, 496)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(13, 13, 13)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //validacion del campo para aceptar solamente numeros
    private void cZonaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cZonaKeyTyped
      char caracter = evt.getKeyChar();
      if((Character.isDigit(caracter)== false && caracter!= evt.VK_BACK_SPACE )|| cZona.getText().length() >= 2)

                {
                    evt.consume();  
                } 
            
      
        
}//GEN-LAST:event_cZonaKeyTyped

    private void rSolteroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rSolteroActionPerformed
        if(rSoltero.isSelected() == true){
            rCasado.setSelected(false);
        }
}//GEN-LAST:event_rSolteroActionPerformed

    private void registroKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_registroKeyTyped
        char caracter = evt.getKeyChar();
        if(((Character.isDigit(caracter)== false && caracter!= evt.VK_BACK_SPACE)))
        {
           evt.consume();  
           
        } else {nDpi.setEnabled(false);}
        if(registro.getText().isEmpty() == true) nDpi.setEnabled(true);  
            
    }//GEN-LAST:event_registroKeyTyped

    private void nDpiKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nDpiKeyTyped
        char caracter = evt.getKeyChar();
        if(((Character.isDigit(caracter)== false && caracter!= evt.VK_BACK_SPACE))|| nDpi.getText().length()>= 14)
        {
         evt.consume();  
        }  
      
    }//GEN-LAST:event_nDpiKeyTyped

    private void tcasaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tcasaKeyTyped
      char caracter = evt.getKeyChar();

     
      if(((Character.isDigit(caracter)== false && caracter!= evt.VK_BACK_SPACE))|| tcasa.getText().length() >=8)
      {
         evt.consume();  
      }  
      
    }//GEN-LAST:event_tcasaKeyTyped

    private void tcelKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tcelKeyTyped
       char caracter = evt.getKeyChar();

     
      if(((Character.isDigit(caracter)== false && caracter!= evt.VK_BACK_SPACE)) || tcel.getText().length() >= 8)
      {
         evt.consume();  
      }  
      
    }//GEN-LAST:event_tcelKeyTyped

    private void rCasadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rCasadoActionPerformed
        if(rCasado.isSelected() == true){
            rSoltero.setSelected(false);
        }
    }//GEN-LAST:event_rCasadoActionPerformed

    private void rSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rSiActionPerformed
        if(rSi.isSelected() == true){
            rNo.setSelected(false);
        }
    }//GEN-LAST:event_rSiActionPerformed

    private void rNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rNoActionPerformed
        if(rNo.isSelected()== true){
            rSi.setSelected(false);
        }
    }//GEN-LAST:event_rNoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
         SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
        Date d = null;
        boolean insertar = true;
        boolean EstadoCivil = false;
        boolean SabeFirmar = false;
        ProcsInsertar InCliente = new ProcsInsertar();
        String nomCliente = tNombre.getText();
        String apeCliente = tApellido.getText();
        String fechaNac = cAnio.getSelectedItem().toString()+"-"+cMes.getSelectedItem().toString()+"-"+cDia.getSelectedItem().toString();
        int NoOrden=0;
        String NoRegistro = null;
        BigInteger DPI = null;
        String DirCliente;
        DirCliente = tDir.getText();
        
        try {
            d = sdf.parse(fechaNac);
        } catch (ParseException ex) {
            Logger.getLogger(NuevoCliente.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (tNombre.getText().isEmpty() || tApellido.getText().isEmpty() || tDir.getText().isEmpty() || cZona.getText().isEmpty() || tcasa.getText().isEmpty()){
            insertar = false; 
            JOptionPane.showMessageDialog(null, "Complete los Campos Faltantes");
        }
        if ((!rSoltero.isSelected() && !rCasado.isSelected()) || (rSoltero.isSelected() && rCasado.isSelected())){
            insertar = false;
            JOptionPane.showMessageDialog(null,"Eliga Estado Civil");
        }
        
        if (!rSi.isSelected() && !rNo.isSelected()) {
            JOptionPane.showMessageDialog(null, "Seleccione si el clienta sabe o no firmar!");
            insertar = false;
        }
        if (rSoltero.isSelected()) EstadoCivil = true;
        if (rCasado.isSelected()) EstadoCivil = false;
        if (rSi.isSelected()) SabeFirmar = true;
        if (rNo.isSelected())SabeFirmar = false;
        if (!registro.getText().isEmpty()){
            NoOrden = Integer.parseInt(registro.getText());
            NoRegistro = cOrden.getSelectedItem().toString();
        }
        if (!nDpi.getText().isEmpty()) DPI = new BigInteger (nDpi.getText());
        if (!registro.getText().isEmpty() && !nDpi.getText().isEmpty()) {
            insertar = false;
            JOptionPane.showMessageDialog(null,"Ingrese Cedula o el Dpi");
        }
        if (registro.getText().isEmpty() && nDpi.getText().isEmpty()) {
            insertar = false;
            JOptionPane.showMessageDialog(null,"Debe Ingresar solo la Cedula o solo el Dpi");
        }
          if (insertar){
            int Zona = Integer.parseInt(cZona.getText());
            java.sql.ResultSet rs = null ;
            String IdMun = null;        
            try {
                rs = InCliente.obtenerIdMunicipio(cMunicipio.getSelectedItem().toString(),IdDepartamento);
                while (rs.next()){
                    IdMun = rs.getObject("idMunicipio").toString();
                }
            } catch (SQLException ex) {
                Logger.getLogger(NuevoCliente.class.getName()).log(Level.SEVERE, null, ex);
            }
            int idMunicipio = Integer.parseInt(IdMun);
            InCliente.insertarDireccionCliente(DirCliente,Zona,idMunicipio);
            InCliente.insertarCliente(nomCliente,apeCliente,fechaNac,EstadoCivil,SabeFirmar,NoOrden,NoRegistro,DPI); 
            if (!tcasa.getText().isEmpty()) InCliente.insertarTelefonoCliente(tcasa.getText(), 1);
            if(tcasa.getText().isEmpty()) InCliente.insertarTelefonoCliente("",1);
            if (!tcel.getText().isEmpty()) InCliente.insertarTelefonoCliente(tcel.getText(), 2);
            if(tcel.getText().isEmpty()) InCliente.insertarTelefonoCliente("",2);
            JOptionPane.showMessageDialog(null, "Cliente Ingresado Exitosamente");
            
        tNombre.setText("");
        tApellido.setText("");
        tDir.setText("");
        cZona.setText("");
        registro.setText("");
        nDpi.setText("");
        tcasa.setText("");
        tcel.setText("");
        rCasado.setSelected(false);
        rSoltero.setSelected(false);
        rSi.setSelected(false);
        rNo.setSelected(false);
        contZona = 0;
            
            
        }
        
       
    }//GEN-LAST:event_jButton1ActionPerformed

    private void cDeptoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cDeptoItemStateChanged
         cMunicipio.removeAllItems();
        ProcsInsertar InCliente = new ProcsInsertar();
         java.sql.ResultSet rs = null ;
         String idDepto = null;
        try {
            rs = InCliente.obtenerIdDepartamento(cDepto.getSelectedItem().toString());
        } catch (SQLException ex) {
            Logger.getLogger(NuevoCliente.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            while (rs.next()){
               idDepto = rs.getObject("idDepartamento").toString();
            }
            IdDepartamento = Integer.parseInt(idDepto);
        } catch (SQLException ex) {
            Logger.getLogger(NuevoCliente.class.getName()).log(Level.SEVERE, null, ex);
        }
       
        try {
            java.sql.ResultSet rss= InCliente.verMunicipios(IdDepartamento);
            while (rss.next()){
                cMunicipio.addItem(rss.getObject("Nombre_municipio"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(NuevoCliente.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cDeptoItemStateChanged

    private void cZonaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cZonaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cZonaActionPerformed

    
   
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                JFrame.setDefaultLookAndFeelDecorated(true);
                new NuevoCliente().setVisible(true);
            }
        });
    }
    int contZona = 0;
    String[] nuevotel = new String[2];
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel Apellido;
    private javax.swing.JComboBox cAnio;
    private javax.swing.JComboBox cDepto;
    private javax.swing.JComboBox cDia;
    private javax.swing.JComboBox cMes;
    private javax.swing.JComboBox cMunicipio;
    private javax.swing.JComboBox cOrden;
    private javax.swing.JTextField cZona;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JTextField nDpi;
    private javax.swing.JRadioButton rCasado;
    private javax.swing.JRadioButton rNo;
    private javax.swing.JRadioButton rSi;
    private javax.swing.JRadioButton rSoltero;
    private javax.swing.JTextField registro;
    private javax.swing.JTextField tApellido;
    private javax.swing.JTextField tDir;
    private javax.swing.JTextField tNombre;
    private javax.swing.JTextField tcasa;
    private javax.swing.JTextField tcel;
    // End of variables declaration//GEN-END:variables
}
